perm filename LECT3.TEX[ARK,TEX] blob sn#766829 filedate 1984-08-19 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00005 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	% copyright 1984 by Arthur Keller ... All rights reserved
C00024 00003	\section{State-Changing Macros vs. Macros with Parameters}
C00031 00004	\section{Fonts \& Magnification}
C00037 00005	\section*{Assignment}
C00038 ENDMK
C⊗;
% copyright 1984 by Arthur Keller ... All rights reserved
\chapter{Sample document from start to finish}

%Mon, August 20
%
%11am-12n
%Sample document from start to finish
%>Interpreting and correcting errors
%>Fonts and magnification
%>Proofreading marks
%>Typesetting language and concepts
%>State changing macros vs. macros with parameters
%
%1-3pm
%<lab assignment 1>

We begin this lecture by looking at the sample document ``My Trip to
Stanford'' and the input which produced it.
These are shown on the following pages.
Although the meaning of each command in the input file will not be clear to
you at this point, having a general sense of what a \TeX\ input file looks
like and how some commands work will be valuable when we go over \TeX\
fundamentals in more detail later.
The sample output was prepared to illustrate a variety of different things
that \TeX\ is capable of doing, and how you ask for them.

\begin{figure}[p]
\vskip6truein
\caption{My trip to Stanford output INTRO1}
\end{figure}

\begin{figure}[p]
\vskip6truein
\caption{My trip to Stanford input INTRO1}
\end{figure}

The first line of the input file reads \cmd{centerline \lb\bs bf My Trip
to Stanford\rb}.
\cmd{centerline} is a control sequence which puts the bracketed material
which follows it (called it's ``argument'') on a line by itself centered
between the left and right margins on the page.
The brackets delimit the material to be centered.
\cmd{bf} is a control sequence which puts the text which follows into
boldface.
In this case, it also applies only to the text within the brackets, which
here serve to delimit both the material to be centered and that to be
boldfaced.

The next line of the input file says \cmd{bigskip}; it tells \TeX\ to
put about 12 points (roughly $1/6$ of an inch) of {\sl vertical} space
after the first line.
If we wanted less space, we could have used \cmd{medskip} (for about 6 points)
or \cmd{smallskip} (for about 3 points).
The reason we say ``about 12 points'' is that these commands specify that the
space may be a little larger or a little smaller in order to avoid a bad
break, such as a widow line or a break after a heading.
That is, these commands specify a certain amount of ``stretch'' and ``shrink.''
If you wanted to change the amount of space that was given for each \cmd{bigskip},
you could redefine what \cmd{bigskip} means.

If we wanted more space at just this one place in the output, say 36 points,
we could use three \cmd{bigskip}s in a row, or \cmd{bigskip\bs bigskip\bs bigskip}.
Alternatively, we could define a new command (or ``macro,'' as they are commonly
called) such as \cmd{megaskip} which would insert space in the amount we
wanted.
There is a command, \cmd{vskip}, that allows you to specify the exact amount
of space wanted (and also allows ``stretch'' and ``shrink'' to be specified).

As might be expected, the next input line,
\cmd{rightline\lb Arthur Keller\rb}, places the instructor's name flush
right on the page.

After the second \cmd{bigskip}, the input file contains several sentences
of text.
By comparing the input file to the output it produced, several things
become apparent.
First, \TeX\ automatically indents the beginning of each new paragraph.
(Even though there was no blank line after the second \cmd{bigskip}, \TeX\
always begins a new paragraph after inserting vertical space.)
The amount of indentation is controlled by the value of \cmd{parindent},
which is 20 points in what is known as ``plain \TeX,'' although you can
set it to another value.
You can also specify that the next paragraph not be indented by giving the
command \cmd{noindent} at the start of the paragraph.

The next thing to notice is that \TeX's output is justified and filled,
even though the input file had words all over the place.
Also, as claimed, everything on a line which occured after a {\tt\%} was
ignored when \TeX\ processed the input.
To specify that part of the document should be in italics, the input file
included the command \cmd{it} inside brackets with the text to be
italicized.
\TeX\ considered everything it saw to be part of the same paragraph until
it came to a blank line in the input.
If you are in a paragraph, a blank line will end it.
(You can also use \cmd{par}.)
If you are not in a paragraph, \TeX\ will begin one when it reads ordinary
text (other than \TeX\ commands) or when it reads a \cmd{noindent}

The next paragraph in the output illustrates the use of accent marks.
\TeX\ treats certain control sequences as instructions to place an accent
over (or, in some cases, below, if you consider the cedilla an accent)
the next character.

In looking at the input file, notice that the control sequence \cmd{c} has
a space after it in the word {\tt Fren\bs~c~ch}, while the control
sequence \cmd{'} is not followed by a space in {\tt acc\bs 'ents}.
This is an example of the difference between a {\it control word\/} and a
{\it control symbol\/}.
A control word consists of a backslash followed by a series of letters; it
ends when \TeX\ sees something other than a letter.
Thus, \cmd{c} must be followed by a space in the input file; otherwise
\TeX\ would interpret the input file as invoking the control sequence
\cmd{cch}, which would probably produce an error.
If, on the other hand, you wanted to have \c0 appear in your output, you
could type \cmd{c0} and no space after the \cmd{c} would be necessary,
since \TeX\ would know to end the control sequence when it saw the
non-letter ``zero.''

A control symbol, on the other hand, consists of a backslash followed by a
single non-letter.
No space is necessary after a control symbol, since \TeX\ automatically
ends the control sequence after the initial non-letter.

{\sl Regardless of whether or not a control sequence must be followed by a
space in the {\rm input} file, \TeX\ will ignore any spaces following a
control sequence when it creates the {\rm output} file.}
Thus, when the input file reads {\tt The name \bs TeX is the uppercase
of\dots}, the space after \cmd{TeX} is necessary to tell \TeX\ to terminate
the control sequence and treat the next character as ordinary text to be
typeset.
However, that space does not appear in the output (which reads ``The name
\TeX is \dots''), since \TeX\ ignores any space following a control
sequence.
In order to produce the proper space in the output, it is necessary to put
a ``control space'' in the input file.
A control space is a space which \TeX\ is forced to treat as significant
when it produces the output; it is obtained by typing \cmd{\ } (that is,
backslash followed by a space).
You do not need (or want) to do this when the control sequence should not be
followed by a space, for example when your output reads ``\dots\ calls
it \TeX.
The name \dots'', or when you want to refer to the \TeX book.
\footnote{A digression on using the logo \TeX.
As we have seen, \TeX\ knows its own name, in the sense of there being a
special control sequence that produces the logo.
This control sequence not only lowers the `E', it also moves the letters
closer together.
(Thus you can always tell whether a document was done in \TeX\ by
inspecting the appearance of the word \TeX!)
Since it is impossible to lower a character on a terminal, the convention
is to write the name as {\tt TeX}.}

This paragraph also contains a dash, which was produced by typing {\tt
\char '055\char '055\char '055}.
There are actually four kinds of dashes which \TeX\ recognizes, as follows:

\des{-} A {\sl hyphen}, used in compound words such as ``pre-emptive'', is
produced by typing a single hyphen ({\tt \char '055}) in the input file.

\des{--} An {\sl en-dash}, used in number ranges such as ``pages 5--7'',
is produced by typing two hyphens in the input file.

\des{---} An {\sl em-dash}---which is twice the size of an en-dash---is
used for parenthetical remarks or breaks in the train of thought (as
illustrated by this sentence), or for attribution of quotations when the
author's name appears preceded by an em-dash at the bottom of the quotation.
It is produced by typing three hyphens in
the input file.  It isn't considered good form---at least by typestting
conventions---to have lots of these in your text.

\des{$-$} A minus sign, which is produced by typing a single hyphen in
math mode (that is, between dollar signs).
In math model, \TeX\ automatically fixes the spacing so that this looks
like a minus sign and not a hyphen.

Note that in the sample output, \TeX\ left space after the em-dash in the
phrase ``We can put acc\'ents in our document--- even \"umla\"uts!''
This is because the input file contained three hyphens followed by a \ret;
since \TeX\ treats a \ret\ as a space, it inserted a space in the output
after the em-dash.
To avoid this happening (assuming that you do not want space before or
after an em-dash), the author could have placed a {\tt \%} at the end of
the line of the input file immediately following the three hyphens, which
would have caused \TeX\ to not treat the \ret\ as part of the text.
Alternatively, the author could have moved the next word {\tt even} onto
the input line immediately following the three hyphens.

This paragraph also illustrates how you can get Greek characters into your
output.
Each Greek character is obtained by typing the appropriate control
sequence, consisting of a backslash followed by the name of the character;
however these control sequences only work inside math mode.

Skipping down to the fourth paragraph in the output, we see some examples
of the kinds of things that \TeX\ can do in math mode.
A variety of mathematical symbols, such as the $\int$, are available in
the same way Greek letters are, by typing the appropriate control sequence
inside of math mode.
Equations should always be done inside of math mode in order to get the
spacing right.
That is, you should type {\tt \$6 < 7\$}, not {\tt 6 \$<\$ 7}.
The $+$ and $-$ are obtained by typing (inside math mode) the plus-sign
and hyphen on your terminal, respectively, while the $\times$ and $\div$
are obtained by typing \cmd{times} and \cmd{div} (in math mode).

The equation in the middle of the page was done in what is known as
``display math mode,'' which causes \TeX\ to put a formula on a line by
itself centered between the left and right margins of the page.
Display math mode is entered (and exited) by typing two dollar signs, as
opposed to one dollar sign for ordinary math mode.
Notice that, although there is extra space above and below the formula,
the text that follows it (``That's quite\dots) is still considered
to be part of the same paragraph, as indicated by the fact that it is not
indented.
This is because there is no blank lines between the double dollar signs
({\tt \$\$}) that end math mode and the first word of the next sentence.

The summation sign was obtained with the control sequence \cmd{sum} inside
display math mode, with the indices {\tt i=1} and \cmd{infty} typed as
sub- and superscript to the control sequence \cmd{sum}.
Note that {\tt i=1} is typed inside braces; otherwise, \TeX\ would treat
only the first charater of input it saw, the {\tt i}, as the text to be
sub-scripted.
The argument to the summation was type using the \cmd{over} command, which
creates a ``built-up fraction''; note that the whole argument is again
delimited with braces.

There are a few peculiarities to math mode.
Inside math mode, all letters appear in italics, and \TeX\ ignores all
spaces, so that {\tt \$a series of words\$} comes out as $a series of
words$.
If we want regular text inside math mode, we can put it inside braces
and use \cmd{rm} as we do with ordinary text.
This is why the label ``Zeno'' is in roman type.
In the input file, {\tt (\lb\bs rm Zeno\rb)} is the argument to \cmd{eqno},
a display math mode control sequence that takes an equation number
supplied by the author and places it in parentheses flush right on the
page opposite the displayed equation.
\TeX\ also does funny things with commas inside math mode; if you try to
type a long number broken up with commmas (like {\tt 37,485}), math mode
will give you $37,485$.
This is because {\tt \$f(x,y)\$} gives you $f(x,y)$, which has a little
space after the comma.

The next paragraph in the sample document was created by the command
\cmd{par} in the input file, which tells \TeX\ to finish the current
paragraph and begin a new one even though there is no blank line in the
input file.
The paragraph after that began with the command \cmd{noindent}, which
turned off indentation for that paragraph.

The space between the paragraphs ``And you can\dots'' and ``Let me
get\dots'' was created with the command \cmd{vfill}, which tells \TeX\ to
fill the page with blank space.
Why did \TeX\ not put the remaining text at the very bottom of the page?
It turns out that the command which ended the input file (\cmd{bye})
also contains a space-filling command, which causes the extra space to be
split between the bottom of the page and the \cmd{vfill}.
Thus, the text ``Let me\dots'' appears centerd vertically on the
page between ``And you can\dots'' and the bottom of the page.
If the input file had contained two \cmd{vfill} commands instead of one,
then two-thirds of the remaining space on the page would have appeared
above the ``Let me \dots'' and one-third of the space would have
appeared below it.

Notice finally that the line in the input file {\tt There are some things
that must be ignored.} was ignored, as will be the case with anything
which follows the \cmd{bye} command.

\section{State-Changing Macros vs. Macros with Parameters}

There are two different kinds of macros that exist in \TeX:
{\sl state-changing macros} and {\sl macros with parameters}.
It is very important to distinguish between them.

A state-changing macro is a command which changes the state that \TeX\ is
in.
Once given, it will apply for the rest of your document, unless you
limit its effects to a specific region of text.

For example, if you put the command \cmd{bf} somewhere in your input file,
from that point on, everything in the output would appear in boldface.
(Unless, of course, you gave a command like \cmd{rm} or \cmd{it}
subsequently.)
In order to tell \TeX\ to put just a few words in boldface, it is
necessary to delimit the text which is to be emboldened.
This is done by writing {\tt $\{$ \bs bf just a few words in boldface
$\}$}.
Then only the material inside the braces with the \cmd{bf} command will
appear in boldface; we say that the braces restrict the effect of the
state-changing macro to being ``local'' to that grouping.

A macro with parameters also involves the use of braces, but for a
different reason.
A macro with parameters is a command that acts on what we call its
argument.
Thus, in the example looked at earlier, the macro \cmd{centerline} centers
a particular amount of text; the text to be centered is the argument of
\cmd{centerline}.
Unlike the previous case, where the control sequence and the text it was
to affect both were inside the braces, in this case, the control
sequence appears outside the braces while the material to be acted on
goes inside.
In fact, the \lb\ must be the first thing that \TeX\ sees after it sees
the control sequence (although a space after the control sequence is
permissable).

This point can be made somewhat cleared by looking at what happens if we
use the braces in the wrong way.
If we typed {\tt \bs bf \lb just a few words in boldface \rb}, then \TeX\
would turn on bold-facing, output the words in braces, and then proceed,
putting everything after that in boldface too.
Since the \cmd{bf} was outside the braces, it applies to the entire
document, not just the grouping.

On the other hand, suppose we didn't use braces correctly on a macro with
a parameter.
For example, suppose we typed {\tt \lb\bs centerline text to be centered
\rb}.
Then \TeX\ will take only the first character it sees after the
\cmd{centerline} command, in this case the ``t'' in ``text'', and center
it on a line, with the next line reading ``ext to be centered'' as the
start of a new paragraph.
Without braces, \TeX\ assumes that the next character it sees is the
parameter to the macro, and proceeds accordingly.
(Of course, if your parameter only consists of one character, that means
you don't have to type the braces, although doing so does tend to make
understanding your input file easier.)

Another example of the importance of grouping is that if we had omitted
the braces around the {\tt 1 \bs over 2\↑\ i} in the input for the
displayed equation in the sample document, \TeX\ would have treated {\tt
1} as the argument of the summation, and put the whole thing \cmd{over}
$2↑i = 1$, as follows:
$$\sum_{i=1}↑\infty 1 \over 2↑i =
1\eqno(\hbox{Zeno})$$
It's helpful to keep in mind the fact that computers are a lot like
five~year~olds; they will do exactly what you say, especially when you
did not mean it!

Notice that with a macro like \cmd{centerline}, the text to be centered
cannot be wider than the page; otherwise, an ``overfull box'' error
message results.
If this occurs, the solution is to break the text to be centered into two
lines, each of which is the argument to a separate \cmd{centerline}
command.
In deciding where to break the text, one needs to consider both {\it
sense} and {\it balance}\/; the two lines should be of approximately equal
length, but you should not break after prepositions or in other places that
would make the meaning of the text difficult to discern.
In general, sense should be of greater concern than balance.

\section{Fonts \& Magnification}

With \TeX, you can get your own font!
(Well, not really $\ldots$; what you can do is use a font that someone
else has created.)
That is, it is possible to have parts of your output appear in type sizes
other than the default or ``normal'' size for the version of \TeX\ (or
macro package) that you are using.

For example, suppose you want part of your output to appear in slightly
larger type than the rest.
You can define your own font, \cmd{bigfont} to be larger with the command
\cmd{font\bs bigfont=amr10 at 12pt}.
Even though no 12-point version of the AMR font exists, this command
allows you to make use of a font called ``bigfont'', which will consist of
10-point version which has been blown up to be 12 points in size.
\footnote{AMR stands for ``Almost Modern Roman''' it is the latest in the
family of METAFONT-created type faces for use with \TeX.
Although the name {\it Almost} Modern suggests that it is slightly
out-of-date, Almost Modern is in fact more modern than it is predecessor
Computer Modern Roman (CMR)!}

\font\bigfiv=amr5 at 10truept

What we are encountering here is the difference between the {\sl design
size} of a typeface and the {\sl actual size}.
The design size, as the name suggests, is the size the typeface was
designed to be printed at.
A typeface designed to be {\bigfiv 5-point which has been blown up to
10-point} will look quite different from 10-point type: the proportions of
the letters will be different, among other things.

To use our new font, just give the command \cmd{bigfont}.
Remember to enclose it in braces along with the text to be printed in
12-point, unless you want everything that follows to be in 12-point.

There are a number of ways to specify the size of a typeface.
One, as we saw above, is to specify \cmd{font\bs myfont=oldfont at
newsize}, where {\tt oldfont} is the name of an existing typeface
(including its design size) and {\tt newsize} is the size you want to use
it at.

A second way to specify the size is to say \cmd{font\bs myfont=oldfont
scaled number}, where {\tt number} is the ``scale factor'', and represents
a magnification factor times 1000.
Thus, we could have written \cmd{font \bs myfont=amr10 scaled 1200} to get
it at 12-point.
Or, we can specify a size using the \cmd{magstep} command, where each {\tt
magstep} represents a power of 1.2.
Thus, we could have written \cmd{font\bs myfont=amr10 \magstep 1} for
12-point type.
The \cmd{magstep}s are available from 1 to 5, and also at \cmd{magstephalf},
which produces output $\sqrt{1.2}$ times the design size.

It is also possible to make everything in your whole document bigger, by
putting a \cmd{magnification\bs magstep1} command at the beginning of the
document.
This will increase the type sizes (and all space which you have requested)
by 1.2 which you have specified.
Furthermore, different magnification commands are cumulative; if you have
a font scaled by \cmd{magstep1} and your entire document has
\cmd{magnification\magstep1}, that font will come out at \cmd{magstep2},
or $1.44={1.2}↑2$ it's design size.
(You could use a \cmd{magnification\bs magstep2} command at the beginning
of the document to get everything 1.44 times as big.)

It is also possible to give \TeX\ dimensions which are independent of any
magnification which is is effect, by putting the word ``true'' before the
dimensions.
Forexample, \cmd{vskip 2truein} will always give you 2 inches of vertical
space, regardless of any magnification which is in effect, while the
amount of space you get with just \cmd{vskip 2in} will be a function of
the amount of magnification.

\section*{Assignment}

Reading for this lecture:  The \TeX book Chapters~4--10.

Assignment for this lecture: Read Chapter 6 of the \TeX book and do what
it says.
Everything.